package app_core

import (
	
	"github.com/flipped-aurora/gin-vue-admin/server/global"
    "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
    "github.com/flipped-aurora/gin-vue-admin/server/model/app_core"
    app_coreReq "github.com/flipped-aurora/gin-vue-admin/server/model/app_core/request"
    "github.com/gin-gonic/gin"
    "go.uber.org/zap"
)

type HbjgCampusLocationApi struct {}



// CreateHbjgCampusLocation 创建建筑表
// @Tags HbjgCampusLocation
// @Summary 创建建筑表
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param data body app_core.HbjgCampusLocation true "创建建筑表"
// @Success 200 {object} response.Response{msg=string} "创建成功"
// @Router /hbjgCampusLocation/createHbjgCampusLocation [post]
func (hbjgCampusLocationApi *HbjgCampusLocationApi) CreateHbjgCampusLocation(c *gin.Context) {
    // 创建业务用Context
    ctx := c.Request.Context()

	var hbjgCampusLocation app_core.HbjgCampusLocation
	err := c.ShouldBindJSON(&hbjgCampusLocation)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	err = hbjgCampusLocationService.CreateHbjgCampusLocation(ctx,&hbjgCampusLocation)
	if err != nil {
        global.GVA_LOG.Error("创建失败!", zap.Error(err))
		response.FailWithMessage("创建失败:" + err.Error(), c)
		return
	}
    response.OkWithMessage("创建成功", c)
}

// DeleteHbjgCampusLocation 删除建筑表
// @Tags HbjgCampusLocation
// @Summary 删除建筑表
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param data body app_core.HbjgCampusLocation true "删除建筑表"
// @Success 200 {object} response.Response{msg=string} "删除成功"
// @Router /hbjgCampusLocation/deleteHbjgCampusLocation [delete]
func (hbjgCampusLocationApi *HbjgCampusLocationApi) DeleteHbjgCampusLocation(c *gin.Context) {
    // 创建业务用Context
    ctx := c.Request.Context()

	ID := c.Query("ID")
	err := hbjgCampusLocationService.DeleteHbjgCampusLocation(ctx,ID)
	if err != nil {
        global.GVA_LOG.Error("删除失败!", zap.Error(err))
		response.FailWithMessage("删除失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("删除成功", c)
}

// DeleteHbjgCampusLocationByIds 批量删除建筑表
// @Tags HbjgCampusLocation
// @Summary 批量删除建筑表
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{msg=string} "批量删除成功"
// @Router /hbjgCampusLocation/deleteHbjgCampusLocationByIds [delete]
func (hbjgCampusLocationApi *HbjgCampusLocationApi) DeleteHbjgCampusLocationByIds(c *gin.Context) {
    // 创建业务用Context
    ctx := c.Request.Context()

	IDs := c.QueryArray("IDs[]")
	err := hbjgCampusLocationService.DeleteHbjgCampusLocationByIds(ctx,IDs)
	if err != nil {
        global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
		response.FailWithMessage("批量删除失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("批量删除成功", c)
}

// UpdateHbjgCampusLocation 更新建筑表
// @Tags HbjgCampusLocation
// @Summary 更新建筑表
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param data body app_core.HbjgCampusLocation true "更新建筑表"
// @Success 200 {object} response.Response{msg=string} "更新成功"
// @Router /hbjgCampusLocation/updateHbjgCampusLocation [put]
func (hbjgCampusLocationApi *HbjgCampusLocationApi) UpdateHbjgCampusLocation(c *gin.Context) {
    // 从ctx获取标准context进行业务行为
    ctx := c.Request.Context()

	var hbjgCampusLocation app_core.HbjgCampusLocation
	err := c.ShouldBindJSON(&hbjgCampusLocation)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	err = hbjgCampusLocationService.UpdateHbjgCampusLocation(ctx,hbjgCampusLocation)
	if err != nil {
        global.GVA_LOG.Error("更新失败!", zap.Error(err))
		response.FailWithMessage("更新失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("更新成功", c)
}

// FindHbjgCampusLocation 用id查询建筑表
// @Tags HbjgCampusLocation
// @Summary 用id查询建筑表
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param ID query uint true "用id查询建筑表"
// @Success 200 {object} response.Response{data=app_core.HbjgCampusLocation,msg=string} "查询成功"
// @Router /hbjgCampusLocation/findHbjgCampusLocation [get]
func (hbjgCampusLocationApi *HbjgCampusLocationApi) FindHbjgCampusLocation(c *gin.Context) {
    // 创建业务用Context
    ctx := c.Request.Context()

	ID := c.Query("ID")
	rehbjgCampusLocation, err := hbjgCampusLocationService.GetHbjgCampusLocation(ctx,ID)
	if err != nil {
        global.GVA_LOG.Error("查询失败!", zap.Error(err))
		response.FailWithMessage("查询失败:" + err.Error(), c)
		return
	}
	response.OkWithData(rehbjgCampusLocation, c)
}
// GetHbjgCampusLocationList 分页获取建筑表列表
// @Tags HbjgCampusLocation
// @Summary 分页获取建筑表列表
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param data query app_coreReq.HbjgCampusLocationSearch true "分页获取建筑表列表"
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取成功"
// @Router /hbjgCampusLocation/getHbjgCampusLocationList [get]
func (hbjgCampusLocationApi *HbjgCampusLocationApi) GetHbjgCampusLocationList(c *gin.Context) {
    // 创建业务用Context
    ctx := c.Request.Context()

	var pageInfo app_coreReq.HbjgCampusLocationSearch
	err := c.ShouldBindQuery(&pageInfo)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	list, total, err := hbjgCampusLocationService.GetHbjgCampusLocationInfoList(ctx,pageInfo)
	if err != nil {
	    global.GVA_LOG.Error("获取失败!", zap.Error(err))
        response.FailWithMessage("获取失败:" + err.Error(), c)
        return
    }
    response.OkWithDetailed(response.PageResult{
        List:     list,
        Total:    total,
        Page:     pageInfo.Page,
        PageSize: pageInfo.PageSize,
    }, "获取成功", c)
}

// GetHbjgCampusLocationPublic 不需要鉴权的建筑表接口
// @Tags HbjgCampusLocation
// @Summary 不需要鉴权的建筑表接口
// @Accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{data=object,msg=string} "获取成功"
// @Router /hbjgCampusLocation/getHbjgCampusLocationPublic [get]
func (hbjgCampusLocationApi *HbjgCampusLocationApi) GetHbjgCampusLocationPublic(c *gin.Context) {
    // 创建业务用Context
    ctx := c.Request.Context()

    // 此接口不需要鉴权
    // 示例为返回了一个固定的消息接口，一般本接口用于C端服务，需要自己实现业务逻辑
    hbjgCampusLocationService.GetHbjgCampusLocationPublic(ctx)
    response.OkWithDetailed(gin.H{
       "info": "不需要鉴权的建筑表接口信息",
    }, "获取成功", c)
}
